package com.turing.post.organization.util;

import java.io.Serializable;
import java.util.Date;

import javax.naming.InitialContext;

import com.turing.post.util.PCPSApplicationException;

/**
 * @author zxp
 * @Apr 11, 2013
 */
@SuppressWarnings("serial")
public class BankTranBusinessAgent implements Serializable{

	private static final BankTranBusiness getBankTranBusinessByBankManage(
			BankManage bm) throws PCPSApplicationException {
		try {
			InitialContext ctx = new InitialContext();
			BankTranBusiness btb = (BankTranBusiness) ctx.lookup(bm
					.getJNDIName()
					+ "#" + BankTranBusiness.class.getName());
			return btb;
		} catch (Exception ex) {
			throw new PCPSApplicationException("", "实现类未找到!");
		}
	}

	/**
	 * 卡发行预处理
	 */
	public static final void BankCardIssuePre(BankManage bm, String cardNo,
			Object privobj) throws PCPSApplicationException {
		getBankTranBusinessByBankManage(bm).BankCardIssuePre(bm, cardNo,
				privobj);
	}

	/**
	 * 卡发行后处理
	 */
	public static final void BankCardIssuePost(BankManage bm, String cardNo,
			Object privobj) throws PCPSApplicationException {
		getBankTranBusinessByBankManage(bm).BankCardIssuePost(bm, cardNo,
				privobj);
	}

	/**
	 * 卡特殊业务处理
	 */
	public static final void BankCardSpecial(BankManage bm, String cardNo,
			String tranType, Object privobj) throws PCPSApplicationException {
		getBankTranBusinessByBankManage(bm).BankCardSpecial(bm, cardNo,
				tranType, privobj);
	}

	/**
	 * 卡联机转账(转入、转出)
	 */
	public static final void BankCardOnlineTransfer(BankManage bm,
			String localSeqNo) throws PCPSApplicationException {
		getBankTranBusinessByBankManage(bm).BankCardOnlineTransfer(bm,
				localSeqNo);
	}

	/**
	 * 联机交易对账
	 */
	public static final void BankCardCheckAccount(BankManage bm, Date tranDate,Object privobj)
			throws PCPSApplicationException {
		getBankTranBusinessByBankManage(bm).BankCardCheckAccount(bm, tranDate,privobj);
	}
}
